public class StringReplace {
    public static String replacePlaceholders(String input, String[] params) {
        int paramIndex = 0;
        StringBuilder result = new StringBuilder();
        
        for (int i = 0; i < input.length(); i++) {
            if (i < input.length() - 1 && input.charAt(i) == '%' && input.charAt(i + 1) == 's') {
                if (paramIndex < params.length) {
                    result.append(params[paramIndex]);
                    paramIndex++;
                    i++; // Skip the second '%' character
                } else {
                    // No more parameters, add the '%' character
                    result.append('%');
                }
            } else {
                result.append(input.charAt(i));
            }
        }
        
        // Append any remaining parameters
        while (paramIndex < params.length) {
            result.append(params[paramIndex]);
            paramIndex++;
        }
        
        return result.toString();
    }

    public static void main(String[] args) {
        String input = "A%sC%sE";
        String[] params = {"B", "D", "F"};
        String output = replacePlaceholders(input, params);
        System.out.println(output); // 输出 "ABCDEF"
    }
}
